package com.api.task.gettasks;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.ITaskApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.OrderFilterApiType;
import com.zyncro.api.model.PagedItemsResultApi;
import com.zyncro.api.model.TaskApi;
import com.zyncro.api.model.TaskInfoFieldFilterApiType;
import com.zyncro.api.model.TaskListFilterApiType;

@ContextConfiguration(locations = { "classpath:/task/task-static.xml" })
public class GetTasks extends AbstractApiTest {

	@Value("#{org_staticTasks[toGet].appId}")
	private String userUrn;

	@Value("#{org_staticTasks[toGet].password}")
	private String userPassword;

	@Value("#{org_staticTasks.cantTasksToGet}")
	private int cantTasksToGet;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void testGetTaks() throws ZyncroApiException {

		int pageNumber = 0;
		int itemsPerPage = 0;

		List<String> groups = null;

		TaskListFilterApiType taskType = null;
		TaskInfoFieldFilterApiType orderFilterField = null;
		OrderFilterApiType orderFilterType = null;

		PagedItemsResultApi<TaskApi> result = getApi().getService(ITaskApiService.class).getTasks(pageNumber, itemsPerPage, groups,
				taskType, orderFilterField, orderFilterType);

		Assert.assertEquals(result.getTotalItems(), cantTasksToGet, "Total tasks to get");
	}
}
